import { saveAs } from 'file-saver'

export function downloadFile(url: string, fileName?: string) {
  saveAs(url, fileName)
}

export function formatSize(size: number) {
  if (size < 1024) {
    return `${size} B`
  } else if (size < 1024 * 1024) {
    return `${(size / 1024).toFixed(2)} MB`
  } else {
    return `${(size / 1024 / 1024).toFixed(2)} GB`
  }
}
